<template>
	<view class="container">
		<uni-list>
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="昵称"
				:rightText="user.nickname" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'email-filled'}" title="邮箱"
				:rightText="user.email" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'auth-filled'}" title="性别"
				:rightText="getSex(user.sex)" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'calendar-filled'}" title="创建日期"
				:rightText="user.createTime" />
		</uni-list>
	</view>
</template>

<script setup>
	import {
		getUserProfile
	} from "@/api/system/user"
	import {
		ref,
		getCurrentInstance,
	} from 'vue'
	const {
		proxy
	} = getCurrentInstance();
	const sexs = ref([{
		text: '男',
		value: "0"
	}, {
		text: '女',
		value: "1"
	}])
	
	function getSex(val){
		for(let o of sexs.value) {
			if(o.value === val) return o.text
		}
		return ''
	}

	const user = ref({});
	const getUser = () => {
		getUserProfile().then(response => {
			user.value = response.data
		})
	}
	getUser()
</script>

<style lang="scss">
	//仅设置背景，不推荐在这里写样式代码
	page {
		background-color: #f8f8f8;
	}
</style>